// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   FuncDefDTO.java

package com.hfstu.ifs.dto;

import com.google.common.collect.Lists;
import com.hfstu.framework.util.StringUtil;
import com.hfstu.ifs.model.*;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import org.apache.commons.beanutils.BeanUtils;

// Referenced classes of package com.hfstu.ifs.dto:
//			FuncLayoutDTO

public class FuncDefDTO
{

	private String id;
	private Integer status;
	private Date createTime;
	private Date lastChangeTime;
	private String code;
	private String name;
	private String funcDefGroupId;
	private String funcDefGroupName;
	private String description;
	private Integer orderIndex;
	private String helpUrl;
	private String layoutContent;
	private List funcLayouts;
	private String dtoType;

	public FuncDefDTO()
	{
		status = Integer.valueOf(0);
		funcLayouts = Lists.newArrayList();
		dtoType = "FuncDefDTO";
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getCode()
	{
		return code;
	}

	public void setCode(String code)
	{
		this.code = code;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getFuncDefGroupId()
	{
		return funcDefGroupId;
	}

	public void setFuncDefGroupId(String funcDefGroupId)
	{
		this.funcDefGroupId = funcDefGroupId;
	}

	public String getFuncDefGroupName()
	{
		return funcDefGroupName;
	}

	public void setFuncDefGroupName(String funcDefGroupName)
	{
		this.funcDefGroupName = funcDefGroupName;
	}

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}

	public Integer getOrderIndex()
	{
		return orderIndex;
	}

	public void setOrderIndex(Integer orderIndex)
	{
		this.orderIndex = orderIndex;
	}

	public String getHelpUrl()
	{
		return helpUrl;
	}

	public void setHelpUrl(String helpUrl)
	{
		this.helpUrl = helpUrl;
	}

	public String getLayoutContent()
	{
		return layoutContent;
	}

	public void setLayoutContent(String layoutContent)
	{
		this.layoutContent = layoutContent;
	}

	public List getFuncLayouts()
	{
		return funcLayouts;
	}

	public void setFuncLayouts(List funcLayouts)
	{
		this.funcLayouts = funcLayouts;
	}

	public Integer getStatus()
	{
		return status;
	}

	public void setStatus(Integer status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getLastChangeTime()
	{
		return lastChangeTime;
	}

	public void setLastChangeTime(Date lastChangeTime)
	{
		this.lastChangeTime = lastChangeTime;
	}

	public String getDtoType()
	{
		return dtoType;
	}

	public void setDtoType(String dtoType)
	{
		this.dtoType = dtoType;
	}

	public FuncDefDTO transfer(FuncDef funcDef)
	{
		try
		{
			BeanUtils.copyProperties(this, funcDef);
		}
		catch (IllegalAccessException e)
		{
			e.printStackTrace();
		}
		catch (InvocationTargetException e)
		{
			e.printStackTrace();
		}
		if (funcDef.getFuncDefGroup() != null)
		{
			setFuncDefGroupId(funcDef.getFuncDefGroup().getId());
			setFuncDefGroupName(funcDef.getFuncDefGroup().getName());
		}
		if (funcDef.getFuncLayuts() != null)
		{
			List funcLayouts = funcDef.getFuncLayuts();
			FuncLayoutDTO funcLayoutDTO;
			for (Iterator iterator = funcLayouts.iterator(); iterator.hasNext(); getFuncLayouts().add(funcLayoutDTO))
			{
				FuncLayout funcLayout = (FuncLayout)iterator.next();
				funcLayoutDTO = new FuncLayoutDTO();
				funcLayoutDTO.transfer(funcLayout);
			}

		}
		return this;
	}

	public String toJson()
	{
		StringBuilder json = new StringBuilder();
		json.append("{");
		json.append("\"id\":\"").append(getId()).append("\",");
		json.append("\"code\":\"").append(getCode()).append("\",");
		json.append("\"name\":\"").append(getName()).append("\",");
		json.append("\"orderIndex\":").append(getOrderIndex()).append(",");
		json.append("\"helpUrl\":\"").append(StringUtil.clean(getHelpUrl())).append("\",");
		json.append("\"description\":\"").append(StringUtil.clean(getDescription())).append("\",");
		json.append("\"dtoType\":\"").append(getDtoType()).append("\",");
		json.append("\"funcLayouts\":[");
		FuncLayoutDTO funcLayout;
		for (Iterator iterator = funcLayouts.iterator(); iterator.hasNext(); json.append(funcLayout.toJson()).append(","))
			funcLayout = (FuncLayoutDTO)iterator.next();

		if (json.charAt(json.length() - 1) == ',')
			json.deleteCharAt(json.length() - 1);
		json.append("]");
		json.append("}");
		return json.toString();
	}
}
